<%=@msgs.size %> messages from <%=@to%>:<br/>
<div id='msg'></div>
<br/>
<div id='chat_msgs' style="background-color:#EEA;height:80%;overflow:auto;border:1px solid #770;padding:3px;">
	<%= render(:partial=>'msg', :collection=>@msgs) %>
</div>
<br/>
<div>
	<% form_remote_tag(:url=> {:action => "send_msg"},
        :update => { :success => "msg", :failure => "msg" },
        :before => "$('msg').innerHTML='sending msg...';",
			:after => "$('txt').value='';") do %>
	<input type="hidden" name="to" value="<%=@to%>">
	<input type="text" id="txt" name="msg">
	<%= submit_tag 'Send' %>
	<% end %>
</div>

<%= periodically_call_remote(
 :url => { :action => "refresh_msgs", :to => "#@to"},
 :frequency => '5',
 :update => { :success => "chat_msgs", :failure => "msg" },
 :before => "$('msg').innerHTML='refreshing...';",
 :success => "$('msg').innerHTML='refreshed';")
%>
